/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import control.GuiManager;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import javax.swing.BorderFactory;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author Jojo
 */
public class ObjectCardPilot extends ObjectCard{
    private String wheelDistance = "8";
    private String wheelDiameter = "3";
    private String swapDirection = "false";
    
    public ObjectCardPilot(){
        super("pilot", 9);
        this.setPreferredSize(new Dimension(180,90));
        this.setSize(new Dimension(180,90));
        this.setMaximumSize(new Dimension(180,90));
        this.setMinimumSize(new Dimension(180,90));
        this.addContextMenu();
    }
    
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g.create();
        Dimension d = this.getSize();
        g2d.drawLine(0,20,d.width-2,20);
        g2d.drawString("radDurchmesserInCm = "+wheelDiameter,  10,35);
        g2d.drawString("radAbstandInCm = "+wheelDistance,  10,55);        
        g2d.drawString("andersrumFahren = "+swapDirection,  10,75);
    }
    
    void addContextMenu(){
        
                
                JMenuItem jmiChangeWheelDiameter = new JMenuItem();
        jmiChangeWheelDiameter.setText("ändere Rad-Durchmesser");

        
        
        jmiChangeWheelDiameter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wheelDiameter = getUserChange("Rad-Durchesser in cm festlegen (z.B. 3.5)");
                repaint();
                validate();
            }
        });
        
        this.jPopupMenu1.add(jmiChangeWheelDiameter);
        
               
                JMenuItem jmiChangeWheelDistance = new JMenuItem();
        jmiChangeWheelDistance.setText("ändere Rad-Abstand");

        
        
        jmiChangeWheelDistance.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                wheelDistance = getUserChange("Rad-Abstand in cm festlegen (z.B. 5.3)");
                repaint();
                validate();
            }
        });
        
        this.jPopupMenu1.add(jmiChangeWheelDistance);
        
                JMenuItem jmiChangeSwapDirection = new JMenuItem();
        jmiChangeSwapDirection.setText("ändere Fahrtrichtung");

        
        
        jmiChangeSwapDirection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                swapDirection = getUserChange("Fahrtrichtung umdrehen? (true oder false?)");
                repaint();
                validate();
            }
        });
        
        this.jPopupMenu1.add(jmiChangeSwapDirection);
    }
    
    void cardClicked(){
        String outputText = "RoboPilot "+ objectName+" = new RoboPilot("+this.wheelDiameter+", "+this.wheelDistance+", "+this.swapDirection+");"+"\n";
        GuiManager.getActivePane().insert(outputText, GuiManager.getActivePane().getCaretPosition());
    }
}
